package topo.action;

import com.l2fprod.common.beans.BaseBeanInfo;
import com.l2fprod.common.beans.ExtendedPropertyDescriptor;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import topo.MainFrame;
import topo.data.NodeLink;
import topo.dialog.LinkViewDialog;
import topo.utils.DialogTools;

public class LinkViewAction extends AbstractAction {
    static NodeLink link;

    public LinkViewAction() {
        super("查看链接");
    }

    public void actionPerformed(ActionEvent e) {
        try {
            link = (NodeLink) getValue("ActionDataKeyName");
            LinkViewDialog dialog = new LinkViewDialog(MainFrame.frame, link);
            DialogTools.dialogPack(MainFrame.frame, dialog);
        } catch (Exception ex) {
            DialogTools.showErroMsg(MainFrame.mainFrame, "查看链接信息出错!");
            ex.printStackTrace();
        }
    }

    public static class BeanInfo extends BaseBeanInfo {
        public BeanInfo(boolean isAdd) {
            this.super();
            addProperty("linkName").setReadOnly().setDisplayName("链接key:");
            addProperty("linkDesc").setDisplayName("链接名称:");
            addProperty("fromNode").setReadOnly().setDisplayName("链接起点:");
            addProperty("toNode").setReadOnly().setDisplayName("链接终点:");
            try {
                addProperty("fromPhysicalPort").setDisplayName("起点物理端口号:");
                addProperty("fromNodeIfIndex").setDisplayName("起点网络接口号:");
                addProperty("fromNodeIfName").setDisplayName("起点网络接口名:");

                addProperty("toPhysicalPort").setDisplayName("终点物理端口号:");
                addProperty("toNodeIfIndex").setDisplayName("终点网络接口号:");
                addProperty("toNodeIfName").setDisplayName("终点网络接口名:");

                addProperty("linkBandwidth").setDisplayName("带宽(MByte/S):");
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}